home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Gamer (Italian) 36
/
PC Gamer IT CD 36 2-2.iso
/
VIGDEMO
/
data1.cab
/
Assets
/
scripts
/
lift2.e
< prev
next >
Wrap
Text File
|
1998-09-21
|
5KB
|
752 lines
int Initialize(string type) {
global int mystate;
global real gOpenTime = 5.0;
global real gStayOpenTime = -1.0;
global string gOpenSound = -1;
global string gCloseSound = -1;
global int gMsgSnd = -1;
global int gVoiceOver = -1;
global int gNeedAction = 0;
global int gLockable = 0;
global int gLocked = 0;
global int gAuto = 1;
Reset("dummy");
}
int opensound(string str)
{
gOpenSound = str;
}
int closesound(string str)
{
gCloseSound = str;
}
int autodoor(string str)
{
gAuto = Str2Int(str);
}
int lockdoor(string str)
{
gLockable = Str2Int(str);
}
int Reset(string dummy)
{
Animate(thisObject,1,"open");
AnimSetDirection(thisObject,1);
mystate = 2;
wakeupTime = -1.0;
SetCollidableProperties(thisObject,1,0);
SetStyle(thisObject,1);
if (gLockable == 1)
gLocked = 1;
}
int msgsnd(string str)
{
gMsgSnd = GetSoundIndex(str);
}
int autodoor(string str)
{
gAuto = Str2Int(str);
}
int needaction(string dummy)
{
gNeedAction = 1;
}
int say(string soundname)
{
gVoiceOver = GetBrainVOSoundIndex(soundname);
}
int lockdoor(string str)
{
gLockable = Str2Int(str);
gLocked = gLockable;
}
int start(string dummy)
{
TimedEvent(1);
gLocked = 0;
return 0;
}
int opentime(string time)
{
gOpenTime = Str2Real(time);
}
int staytime(string time)
{
gStayOpenTime = Str2Real(time);
}
int TimedEvent(int input)
{
real time;
real phase;
time = GetTime(thisObject);
switch (mystate)
{
case 2:
if (input == 1)
{
mystate = 1;
wakeupTime = time + gOpenTime;
OpenLowLevel();
}
break;
case 1:
if ( input == 0)
{
phase = AnimGetPhase(thisObject);
if (phase == 1.0)
{
if (gStayOpenTime != -1.0)
{
wakeupTime = time + gStayOpenTime;
}
else
{
wakeupTime = -1.0;
}
mystate = 0;
}
else
{
wakeupTime = time + 0.1;
}
}
break;
case 0:
mystate = 3;
wakeupTime = time + gOpenTime;
CloseLowLevel();
break;
case 3:
if ( input == 0)
{
phase = AnimGetPhase(thisObject);
if (phase == 0.0)
{
mystate = 2;
wakeupTime = -1.0;
}
else
{
wakeupTime = time + 0.1;
}
}
break;
default:
break;
}
}
int OpenLowLevel ()
{
Animate(thisObject,1,"open");
AnimSetDirection(thisObject,0);
PlaySound(thisObject,gOpenSound);
return 0;
}
int CloseLowLevel ()
{
Animate(thisObject,1,"open");
AnimSetDirection(thisObject,1);
PlaySound(thisObject,gCloseSound);
return 0;
}
int Colliders(string dummy) {
int result;
int valid = 1;
int op2;
map::iterator ix;
map::iterator iy;
map objInList;
result = 0;
if (IsAuthoritative(thisObject) != 1)
return result;
if (gAuto == 0)
{
valid = 0;
}
if (valid == 1)
{
if (gLocked == 1)
{
objInList = Collisions(thisObject,0,3,0);
ix = begin(objInList);
iy = end(objInList);
if (ix != iy)
{
if (gNeedAction == 1)
{
for ( ix ; ix != iy; ++ix )
{
op2 = IsOperating(first(dereference(ix)));
if (op2 == 1)
gLocked = 0;
}
}
else
gLocked = 0;
}
if (gLocked == 1)
valid = 0;
}
else
{
if (gNeedAction == 1)
{
valid = 0;
objInList = Collisions(thisObject,0,1,0);
ix = begin(objInList);
iy = end(objInList);
for ( ix ; ix != iy; ++ix )
{
op2 = IsOperating(first(dereference(ix)));
if (op2 == 1)
valid = 1;
}
}
}
if (valid == 1)
{
objInList = Collisions(thisObject,0,1,0);
ix = begin(objInList);
iy = end(objInList);
if (ix != iy)
{
Multicast(thisObject,"start","dum");
}
} else {
SendEnglishMessage(thisObject);
PlayVoiceOver(gVoiceOver);
PlaySound(thisObject,gMsgSnd);
}
}
}